package jym.tan.movielibrary.component.ui.custom;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.GridBagLayout;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseMotionAdapter;

import javax.swing.JComponent;
import javax.swing.UIManager;

public class DisabledGlassPane extends JComponent implements KeyListener {
	
	private static final long serialVersionUID = 40L;

	public DisabledGlassPane() {
		setOpaque(false);
		Color base = UIManager.getColor("inactiveCaptionBorder");
		Color background = new Color(base.getRed(), base.getGreen(), base.getBlue(), 128);
		setBackground(background);
		setLayout(new GridBagLayout());
		addMouseListener(new MouseAdapter() {
		});
		addMouseMotionListener(new MouseMotionAdapter() {
		});

		addKeyListener(this);
		setFocusTraversalKeysEnabled(false);
	}

	@Override
	protected void paintComponent(Graphics graphics) {
		graphics.setColor(getBackground());
		graphics.fillRect(0, 0, getSize().width, getSize().height);
	}

	public void keyPressed(KeyEvent e) {
		e.consume();
	}

	public void keyTyped(KeyEvent e) {
	}

	public void keyReleased(KeyEvent e) {
		e.consume();
	}

	public void activate() {
		setVisible(true);
		setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
		requestFocusInWindow();
	}

	public void deactivate() {
		setCursor(null);
		setVisible(false);
	}
}
